Repository navigation
Examples: use the converters the API spec documents - #73
Merged
Merged
Conversation
The production API spec (https://v2.convertapi.com/info/openapi) has no web -> pdf, any -> zip or docx -> svg converter. - convert_url_to_pdf.php converts the URL with html -> pdf (same Url and FileName parameters) and links the html-to-pdf page. - conversions_chaining.php zips the JPG results with file -> zip. - error_handling.php gets its API error from pdf -> split with a DOCX file (code 4000, the file must be a .pdf) instead of the unsupported docx -> svg conversion (also code 4000). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 9, 2026
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the PHP example updates aligning converter usage with the production API specification.
No open issues 🎉
What changed in this PR
Updates three PHP examples to use converters listed in the production API specification, without changing library behavior.
Changes:
- Uses
html -> pdffor URL conversion and updates the documentation link. - Uses
file -> zipto archive chained conversion results. - Demonstrates error handling with a documented
pdf -> splitconverter and an intentionally invalid DOCX input.
| File | Description |
|---|---|
examples/error_handling.php |
Triggers a file-validation error using PDF split with a DOCX input. |
examples/convert_url_to_pdf.php |
Sets the source format to html and links to HTML-to-PDF documentation. |
examples/conversions_chaining.php |
Sets the ZIP conversion source format to file. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three examples call converters that the production API spec (https://v2.convertapi.com/info/openapi, 332 paths on 2026-11-09) does not list. Developers copy these examples and the how-to guides on convertapi.com reuse them, so they should call documented converters. This is the PHP part of what ConvertAPI/convertapi-library-dotnet#86 does for .NET.
convert_url_to_pdf.phpweb -> pdf, comment links /web-to-pdfhtml -> pdf(parameters), sameUrlandFileName; comment links https://www.convertapi.com/html-to-pdfconversions_chaining.phpany -> zipfile -> zip(parameters), sameFileserror_handling.phpdocx -> svg, which the API rejects as an unsupported conversionpdf -> splitwithfiles/test.docx, which the API rejects because the file is not a PDF (the .NET ExceptionHandling example does the same)https://www.convertapi.com/web-to-pdf is not in the site's sitemap; https://www.convertapi.com/html-to-pdf is. The other examples already call documented converters; the
pdf -> extractstep of create_pdf_thumbnail.php goes away with #72.Verified against production (2026-11-09)
PHP 8.4.27 in Docker (
php:8.4-cli):php -lpasses for the three files. Each example ran withphp <name>.phpfromexamples/, once onmain(8874aff) and once on this branch, with the token inCONVERT_API_SECRETandTMPDIR=/out.conversions_chaining.php, same output before and after:
Both runs saved a 775,249-byte
test.zipwithtest.jpgtotest-6.jpg; the JPGs are byte-identical before and after.convert_url_to_pdf.php, same output before and after:
The PDF text: on this branch the PDF is the article (3 pages, 1,925 words, title "Data conversion"). On
main, Wikimedia answered ConvertAPI's renderer with its "Too many requests" page (1 page, 62 words); that rate limiting comes and goes for both converters and is being looked at separately.error_handling.php, before:
after:
Seen, not changed: the library itself sends
urlas the source format when the parameters have aUrland no source format is given (lib/ConvertApi/Task.php,DEFAULT_URL_FORMAT);urlis not in the spec. The URL example passes its source format, so it does not depend on it.Same change in the other SDKs
🤖 Generated with Claude Code